@extends('admin.mainlayout')
@section('title')
    <div class="title"><span id="test">订单管理</span></div>
    <br/>
    <div class="main_top" >
        <form id='search' action="{{url('center/order')}}" method="get">
            <span>选择时间段</span>
            <input type="text" name="starttime" class="laydate-icon" id="hello2"/><span> -</span>
            <input type="text" name="endtime" class="laydate-icon" id="hello3"/>
            <input type="text" name="keyword" style="width: 120px;height: 21px;margin-left: 100px" placeholder="手机号/昵称"/>
            <span id="sousuo" >搜索</span>
        </form>
    </div>
    <style type="text/css">
        #sousuo{
            display:inline-block;
            background: #347c1e;
            text-align: center;
            color:white;
            height:25px;
            width:40px;
            margin-left: 40px;
            cursor: pointer;
        }
        #sousuo:hover{
            background-color: #2d94e8;
        }
    </style>
@endsection
@section('content')
        <!-- start 充值订单管理-->
    <div class="list1">
        <table id="kuxuan">
            <tr>
                <th>id</th>
                <th>用户手机</th>
                <th>币种</th>
                <th>提交数量</th>
                <th>实际到账</th>
                <th>锁定代币数量</th>
                <th width="10%">25%浮动增加代币</th>
                <th>提交时间</th>
                <th width="15%">到账状态</th>
                <th>操作</th>
            </tr>
            @if(!empty($data['data']))
                @foreach($data['data'] as $v)
            <tr>
                <td>{{$v['id']}}</td>
                <td>{{$v['member']['member_mobile']}}</td>

                <td>
                    @if($v['type']==1)
                    {{'eth'}}
                    @else
                    {{'btc'}}
                    @endif
                </td>
                <td>{{$v['amount']}}</td>
                <td>{{$v['actual_arrival']}}</td>
                <td>{{$v['lock_num']}}</td>
                <td>{{$v['market_fluctuation']}}</td>
                <td>{{$v['updated_at']}}</td>
                <td>{{$v['state']}}</td>
                @if($v['actual_arrival']!=0)
                <td style="color: #0c80ba;cursor: default;">已到账</td>
                @else
                <td id="queren" onclick="queren({{$v['id']}})">确认到账</td>
                @endif
            </tr>
                @endforeach
             @else
                <tr>
                    <td colspan="9">暂无数据(﹀_﹀")......</td>
                </tr>
            @endif
        </table>
    </div>

    <div class="del">
        <div class="bot">
            @if(!empty($data['total']))
            @if($data['prev_page_url'])
                <p class="prev"><a href="{{$data['prev_page_url']}}@if(!empty($_GET['starttime']))&starttime={{trim($_GET['starttime'])}}@endif @if(!empty($_GET['endtime']))&endtime={{$_GET['endtime']}}@endif @if(!empty($_GET['keyword']))&keyword={{$_GET['keyword']}}@endif"><span class="jiazai">上一页</span></a></p>
            @endif
            <ul>
                @foreach($data['pageNoList'] as $v)
                    <li @if($data['current_page'] == $v )class="active_list" @endif ><span class="jiazai"><a href="/center/order/index?page={{$v}}@if(!empty($_GET['starttime']))&starttime={{trim($_GET['starttime'])}}@endif @if(!empty($_GET['endtime']))&endtime={{trim($_GET['endtime'])}}@endif @if(!empty($_GET['keyword']))&keyword={{$_GET['keyword']}}@endif">{{$v}}</a></span></li>
                @endforeach
            </ul>
            @if($data['next_page_url'])
                <p class="next"><a href="{{$data['next_page_url']}}@if(!empty($_GET['starttime']))&starttime={{trim($_GET['starttime'])}}@endif @if(!empty($_GET['endtime']))&endtime={{trim($_GET['endtime'])}}@endif @if(!empty($_GET['keyword']))&keyword={{$_GET['keyword']}}@endif"><span class="jiazai">下一页</span></a></p>
            @endif
                @endif
        </div>

    </div>
    <script>

        //点击发送ajax请求,改变状态
        function queren(id){


                layer.confirm('确认更新这条数据?',{btn:['确定','取消']},function(){
                    console.log(id);
                    $.ajax({
                        type:'post',
                        url:'{{url('center/order/change')}}',
                        dataType:'json',
                        data:{'_token':"{{csrf_token()}}",'id':id},
                        success:function(res){

                            if(res['status']==1){

                                layer.msg(res.msg,{icon:6});
                                setTimeout("location.reload()",1500);

                            }else{

                                layer.msg(res.msg,{icon:5});

                            }

                        }
                    });

                },function(){


                });



        }

        //时间搜索
        var oSousuo = document.getElementById('sousuo');
        var oSearch = document.getElementById('search');

        oSousuo.onclick = function(){
            //加载效果
            layer.load(2, {shade: false});
            oSearch.submit();

        }

        laydate({
            elem: '#hello2'
        });
        laydate({
            elem: '#hello3'
        });

    </script>


@endsection
